package cn.bocai.pc.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bocai.pc.dao.BcUserMapper;
import cn.bocai.pc.model.BcUser;
import cn.bocai.pc.service.BcUserService;


@Service
public class BcUserServiceImpl implements BcUserService{

	@Autowired
	private  BcUserMapper userDao;

	//ajax查询用户名是否存在
	public String selectNameExist(String name) {
		String tempDate="";
		BcUser selectNameExist = userDao.selectNameExist(name);
		if(selectNameExist == null ||"".equals(selectNameExist)){
			tempDate="0";
		}else{
			String username = selectNameExist.getUsername();
			if(username == null ||"".equals(username)){
				tempDate="0";
			}else{
				tempDate="1";
			}
		}
		
		return tempDate;
	}

	
	//查询出指定数据对象
	public BcUser findUserByName(String name) {
		return userDao.selectNameExist(name);
	}
	
	//新用户注册信息存入
	public int insertRegister(BcUser record) {
	  int insertRegister = userDao.insertRegister(record);
		return insertRegister;
	}
	
	//用户登入查询信息进行匹配
	public BcUser selectLogin(BcUser record) {
		BcUser selectLogin = userDao.selectLogin(record);
		return selectLogin;
	}
	
	//登入以后修改用户密码
	public int updateUserPaw(Map<String, Object> par) {
		int updaDate = userDao.updateUserPaw(par);
		return updaDate;
	}
	
	//注册时查询邮箱是否存在
	public String selectEmail(String email) {
		String tempDate="";
		BcUser selectemail = userDao.selectEmail(email);
		if(selectemail == null ||"".equals(selectemail)){
			tempDate="0";
		}else{
			String emails = selectemail.getEmail();
			if(emails == null ||"".equals(emails)){
				tempDate="0";
			}else{
				tempDate="1";
			}
		}
		
		return tempDate;
	}
    //修改数据
	public int updateByPrimaryKeySelective(BcUser record) {
		return userDao.updateByPrimaryKey(record);
	}
	
	//根据id修改数据
	public int updateByPrimaryKey(BcUser record) {
		return userDao.updateByPrimaryKey(record);
	}
	
	//根据id查询出数据
	public BcUser selectByPrimaryKey(String userId) {
		return userDao.selectByPrimaryKey(userId);
	}
	
	public int deleteByPrimaryKey(String userId) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int insertSelective(BcUserMapper record) {
		// TODO Auto-generated method stub
		return 0;
	}

	

	

	
	

}
